package com.woniu40.separate_music.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import com.woniu40.separate_music.entity.Music;
import com.woniu40.separate_music.entity.Music;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface MusicMapper {
    @Select("select count(1) from t_collection where userid = #{userid} and mid = #{musicid}")
    int isCol(@Param("userid") Integer userid,@Param("musicid") Integer musicid);

    @Insert("insert into t_collection (userid ,mid) values (#{userid},#{mid})")
    int col(@Param("userid") int userid , @Param("mid") int mid);

    @Update("update t_music set collectCount = collectCount +1 where musicid = #{id}")
    int updateMusicColAddCount(int mid);
    List<Music> selectMusicBycons(@Param("singer") String singer, @Param("tid")Integer tid);

    @Delete("delete from t_collection where userid = #{userid} and mid = #{mid} ")
    int deleteCollect(@Param("userid")Integer userid, @Param("mid") Integer mid);

    @Update("update t_music set collectCount=collectCount - 1 where musicid = #{musicid} ")
    int updateCount(Integer musicid);

    List<Music> selectMusicByUserid(Integer id);

    int deleteMusic(Integer musicid);

    int deleteCol(Integer musicid);

    int insertMusic(Music music);

}
